package com.kila.CourseFactory;

import com.kila.newinstance.HtmlCourse;
import com.kila.newinstance.ICourse;
import com.kila.newinstance.JavaCourse;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

//课程工厂
public class CourseFactory {
      //根据名字获取课程的方法
      public static ICourse getCourse(String name){
         //先获取ioc容器
          ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");

        if(name.equals("java")){
            return (ICourse) applicationContext.getBean("javaCourse");
        }else {
            return (ICourse) applicationContext.getBean("htmlCourse");
        }



      }


}
